
/* File name	: bkit_mcr_2010.c
 * Project 		: BKIT MCR
 * Version 		: 1.0
 * Creation Date: 07/07/2010
 * Tabsize		: 4
 * Author  		: BKIT4U                   
 * Copyright	: (c) 2010 BKIT HARDWARE CLUB - www.bkit4u.com
 * License		: Free.
 * Comments		: 
 * 
 */


/*====================================*/
/*  Include                           */
/*====================================*/
#include "bkit_mcr_2010.h"

/*====================================*/
/*  interrupt timer1                  */
/*  Description: interrupt timer1 with*/
/*               cycle 1ms used to    */
/*               manage program       */
/*====================================*/
ISR (TIMER1_OVF_vect)
{
	// Reinitialize Timer 1 value
    TCNT1H = 0xc1;	// configure register to have timer 1ms
    TCNT1L = 0x7f;
    
	virtual_timer();

	led_mod();
	beep_mod();
	update_input();

	read_sensor();    
}


/*====================================*/
/*  Function name: main               */
/*  Description: 1. main function     */
/*               2. Initialize system */
/*               3. Run appllication  */
/*====================================*/
int main()
{
	init();         // initialize system
	asm("sei");		// global interrupt enable

	beep_long(300);	// speaker on during 300ms

	test();

	run();
	
	return 1;
}

/*====================================*/
/*  Function name: init               */
/*  Description: 1. Confugure hardware*/
/*               2. Initialize system */
/*====================================*/
void init()
{
	atmega64_init();

	adc_init();
	beep_init();
	led_init();
	handle_init();
	speed_init();
	input_init();
	timer_init();

	read_handle_center ();
	
	handle(0);

	read_vcompare();	//read v_compare values form epprom
}


/*====================================*/
/*  Function name: atmega64_init      */
/*  Description: initial configuration*/
/*              for ATmega64 MCU      */
/*====================================*/
void atmega64_init(){
	// Turn Off Analog Comparator: Off
	ACSR=0x80;
}


/****************END FILE**************/

